<?php
/**
 * 
 * @author	ronnie  (comdeng@gmail.com)
 * @link		http://fillphp.com/
 * @date		2014-5-3 上午2:14:08
 * @file		Date.php
 * @description 
 */
namespace com\demo\helper;

class Date extends \fillphp\helper\Helper
{
	function long($time)
	{
		return date('Y/m/d H:i:s', $time);
	}
	
	function short($time)
	{
		return date('Y/m/d', $time);
	}
	
	function smart($time)
	{
		$now = time();
		$year = date('Y', $now);
		$diff = $now - $time;
		if ($diff < 0) {
			return $this->long($time);
		}
		if($diff<=30)
		{
			return '刚刚';
		}
		if ($diff < 60) {
			return '半分钟前';
		}
		if ($diff < 3600) {
			$minutes = ceil($diff/60);
			return ceil($diff/60).'分钟前';
		}
		$today = strtotime('today');
		if ($time >= $today) {
			return '今天 '.date('H:i', $time);
		}
		if ($today - $time < 86400) {
			return '昨天 '.date('H:i', $time);
		}
		if ($year != date('Y', $time)) {
			return date('Y/m/d H:i', $time);
		}
		return date('m/d H:i', $time);
	}
}